Contents | Index | < Browse | Browse >
LETTERfcloseULETTER
Closes an opened file.
Overview
#include <stdio.h>
r = fclose(FILE *f)
int r; // result
FILE *fp; // file pointer
Portability
ANSI
Description
All opened files must of course also be closed sooner or later (preferrably
as soon as possible). The "fclose" function closes a file which was previously
opened with "fopen" and releases the associated "FILE" structure. Before this
all buffers will be written (similar to "fflush") and freed.
"fclose" will be automatically called if your program is terminated with
"exit" and there are any open files left. It is however good practise to
close the files you opened yourself.
Returns
Possible return values are zero and "EOF" in case of an error. If "EOF" is
returned further information may be obtained from the "errno" variable.
See also
fflush , fopen , freopen